package com.kantboot.api.phone.repository;

import com.kantboot.api.phone.domain.entity.ApiPhoneBelongTo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface ApiPhoneBelongToRepository extends JpaRepository<ApiPhoneBelongTo,Long> {

    /**
     * 根据手机号获取归属地
     */
    @Query("""
        FROM ApiPhoneBelongTo a
        WHERE :phone LIKE CONCAT(a.areaCode, a.phonePrefix, '%')
        """)
    ApiPhoneBelongTo findByPhone(@Param("phone") String phone);
}
